package com.ss.android.wenda.model;

import android.os.Handler;
import android.os.Looper;
import android.os.Parcel;
import android.os.Parcelable;
import android.support.design.a;

import com.bytedance.common.utility.collection.WeakList;
import com.bytedance.common.utility.collection.e;
import com.ss.android.article.common.model.ShareData;

import java.util.List;

public class Answer implements Parcelable {
    public static class Sync implements Parcelable {
        public static final Parcelable.Creator CREATOR;
        public int buryCount;
        public int diggCount;
        public boolean isBury;
        public boolean isDigg;
        public int readCount;
        private static e sSyncMap;

        static {
            CREATOR = new c();
        }

        public Sync() {

        }

        protected Sync(Parcel arg4) {
            boolean v1 = true;

            this.diggCount = arg4.readInt();
            boolean v0 = arg4.readByte() != 0 ? true : false;
            this.isDigg = v0;
            this.buryCount = arg4.readInt();
            if (arg4.readByte() == 0) {
                v1 = false;
            }

            this.isBury = v1;
            this.readCount = arg4.readInt();
        }

        public int describeContents() {
            return 0;
        }

        public static Sync get(String arg2) {
            Object v0_1;
            Sync v0;
            if (a.isTextEmpty(arg2)) {
                v0_1 = null;
            } else {
                if (Sync.sSyncMap == null) {
                    Sync.sSyncMap = new e();
                }

                v0_1 = Sync.sSyncMap.a(arg2);
                if (v0_1 != null) {
                    return (Sync) v0_1;
                }

                v0_1 = new Sync();
                Sync.sSyncMap.a(arg2, v0_1);
            }

            return ((Sync) v0_1);
        }

        public void writeToParcel(Parcel arg4, int arg5) {
            byte v1 = 1;
            arg4.writeInt(this.diggCount);
            byte v0 = (byte) (this.isDigg ? 1 : 0);
            arg4.writeByte(v0);
            arg4.writeInt(this.buryCount);
            if (!this.isBury) {
                v1 = 0;
            }

            arg4.writeByte(v1);
            arg4.writeInt(this.readCount);
        }
    }

    public interface Answer$a {
        void l();
    }

    public static final Parcelable.Creator CREATOR;
    public static final WeakList LISTENERS;
    private static final Handler MAIN_HANDLER;
    public String mAnsId;
    public String mAnsUrl;
    public AnswerAbstract mAnswerAbstract;
    public String mContent;
    public long mCreateTime;
    public boolean mIsShowBury;
    public UserPrivilege mPrivilege;
    public String mSchema;
    public ShareData mShareData;
    public Sync mSync;
    public User mUser;

    static {
        MAIN_HANDLER = new Handler(Looper.getMainLooper());
        LISTENERS = new WeakList();
        CREATOR = new com.ss.android.wenda.model.b();
    }

    protected Answer(Parcel parcel) {
        this.mAnsId = parcel.readString();
        this.mContent = parcel.readString();
        this.mCreateTime = parcel.readLong();
        this.mUser = parcel.readParcelable(User.class.getClassLoader());
        this.mAnswerAbstract = parcel.readParcelable(AnswerAbstract.class.getClassLoader());
        this.mAnsUrl = parcel.readString();
        this.mShareData = parcel.readParcelable(ShareData.class.getClassLoader());
        this.mPrivilege = parcel.readParcelable(UserPrivilege.class.getClassLoader());
        this.mSync = parcel.readParcelable(Sync.class.getClassLoader());
        this.mSchema = parcel.readString();
    }

    public Answer(String arg2) {
        this.mAnsId = arg2;
        this.mSync = Sync.get(arg2);
    }

    public void buryAnswer() {
        if (this.mSync != null) {
            ++this.mSync.buryCount;
            this.mSync.isBury = true;
        }

        Answer.notifyAnswerChanged(this.mAnsId);
    }

    public int describeContents() {
        return 0;
    }

    public void diggAnswer() {
        if (this.mSync != null) {
            ++this.mSync.diggCount;
            this.mSync.isDigg = true;
        }

        Answer.notifyAnswerChanged(this.mAnsId);
    }

    public boolean equals(Object arg5) {
        boolean v0 = true;
        if (this != (((Answer) arg5))) {
            if (!(arg5 instanceof Answer)) {
                v0 = false;
            } else if (this.mAnsId != ((Answer) arg5).mAnsId) {
                v0 = false;
            }
        }

        return v0;
    }

    public AnswerAbstract getAnswerAbstract() {
        return this.mAnswerAbstract;
    }

    public String getAnswerId() {
        return this.mAnsId;
    }

    public String getAnswerUrl() {
        return this.mAnsUrl;
    }

    public int getBuryCount() {
        int v0 = this.mSync != null ? this.mSync.buryCount : 0;
        return v0;
    }

    public String getContent() {
        return this.mContent;
    }

    public long getCreateTime() {
        return this.mCreateTime;
    }

    public int getDiggCount() {
        int v0 = this.mSync != null ? this.mSync.diggCount : 0;
        return v0;
    }

    public List getLargeImageList() {
        List v0 = this.mAnswerAbstract == null ? null : this.mAnswerAbstract.mLargeImageList;
        return v0;
    }

    public ShareData getShareData() {
        return this.mShareData;
    }

    public List getThumbImageList() {
        List v0 = this.mAnswerAbstract == null ? null : this.mAnswerAbstract.mThumbImageList;
        return v0;
    }

    public User getUser() {
        return this.mUser;
    }

    public boolean hasThumbImage() {
        boolean v0 = this.mAnswerAbstract == null || this.mAnswerAbstract.mThumbImageList == null || this.mAnswerAbstract.mThumbImageList.size() <= 0 ? false : true;
        return v0;
    }

    public int hashCode() {
        return this.mAnsId.hashCode();
    }

    public boolean isBury() {
        boolean v0 = this.mSync == null || !this.mSync.isBury ? false : true;
        return v0;
    }

    public boolean isDigg() {
        boolean v0 = this.mSync == null || !this.mSync.isDigg ? false : true;
        return v0;
    }

    public static void notifyAnswerChanged(String arg2) {
        if (!a.isTextEmpty(arg2)) {
            Answer.MAIN_HANDLER.post(new com.ss.android.wenda.model.a());
        }
    }

    public static void registerListener(com.ss.android.wenda.model.Answer.Answer$a arg1) {
        Answer.LISTENERS.add(arg1);
    }

    public void setAnswerAbstract(AnswerAbstract arg1) {
        this.mAnswerAbstract = arg1;
    }

    public void setAnswerUrl(String arg1) {
        this.mAnsUrl = arg1;
    }

    public void setCreateTime(long arg2) {
        this.mCreateTime = arg2;
    }

    public static void unregisterListener(com.ss.android.wenda.model.Answer.Answer$a arg1) {
        Answer.LISTENERS.remove(arg1);
    }

    public void writeToParcel(Parcel arg3, int arg4) {
        arg3.writeString(this.mAnsId);
        arg3.writeString(this.mContent);
        arg3.writeLong(this.mCreateTime);
        arg3.writeParcelable(this.mUser, arg4);
        arg3.writeParcelable(this.mAnswerAbstract, arg4);
        arg3.writeString(this.mAnsUrl);
        arg3.writeParcelable(this.mShareData, arg4);
        arg3.writeParcelable(this.mPrivilege, arg4);
        arg3.writeParcelable(this.mSync, arg4);
        arg3.writeString(this.mSchema);
    }
}

